#ifndef __PID_H__
#define __PID_H__

#include "main.h"
//#include "tim.h"
#include <stdbool.h>
#define pid_debug_pos_inc 0

typedef struct pid_pos
{
	float Kp,Ki,Kd;

	float target;
	float now;
	float last_now;

	float integral;
	float integral_max;

	float last_error;
	float output;
	float output_max;
}pid_pos;

typedef struct pid_inc
{
	float Kp,Ki,Kd;

	float target;
	float now;

	float last_error;
	float output;
	float output_max;

}pid_inc;

//#define PID_TIM &htim1

extern pid_pos pid_angle;
extern pid_inc pid_speed;

void pid_init();
float pid_cal_pos(pid_pos *pid);
void pid_speed_task();
void pid_angle_task();
#endif
